-- 仓库类
require("TSLib")
local toucher = require("toucher")
local logger = require("logger")

local M = {
	row = 5,
	column = 5
	
}

function M.is_open(...)
	if (isColor( 572,  541, 0x38857d, 85)) 
	and  (isColor( 488,  541, 0xfeeac7, 85)) then
		return true
	end
	return false
end


function M.grid(row,column)
	local knapsack_column = {310, 390, 470, 540, 590}
	local knapsack_row = {170, 240, 320, 400, 470}
	return knapsack_column[column], knapsack_row[row]
end


function M.tidy(...)
	if (isColor( 572,  541, 0x38857d, 85)) then
		toucher.click(572,541)
		return true
	else
		logger.warn("the store not open")
		return false
	end
end

-- 取出物品
function M.take_out(...)
	for row = 1, M.row, 1 do
		for column = 1, M.column, 1 do
			x,y = M.grid(row,column)
			toucher.double_click(x,y)
			mSleep(1000)
		end
	end
	M.tidy()
	mSleep(1000)
end

function main(...)
	init(1)
	nLog(M.is_open())
end

--main()

return M